package com.knife.scheduler.api.controller.v1;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.knife.common.utils.Results;
import com.knife.scheduler.app.service.KnifeJobInfoService;
import com.knife.scheduler.domain.entity.KnifeJobInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * 定时任务Controller
 *
 * @author： 76875
 * @date： 2022/4/2 星期六 23:38
 * @description：
 * @modifiedBy：
 * @version: 1.0
 */
@RestController("v1.KnifeJobInfoController")
@RequestMapping("/v1/{organizationId}/job-info")
public class KnifeJobInfoController {

    @Autowired
    private KnifeJobInfoService knifeJobInfoService;


    @GetMapping
    public ResponseEntity<Page<KnifeJobInfo>> selectKnifeJobInfoPage(Page<KnifeJobInfo> page,KnifeJobInfo knifeJobInfo){
        return Results.success(knifeJobInfoService.selectKnifeJobInfoPage(knifeJobInfo,page));
    }

    @PostMapping
    public ResponseEntity<KnifeJobInfo> saveAndUpdateKnifeJobInfo(@PathVariable Long organizationId,@RequestBody KnifeJobInfo knifeJobInfo){
        knifeJobInfoService.saveAndUpdateKnifeJobInfo(knifeJobInfo);
        return Results.success(knifeJobInfo);
    }
}
